#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QtGui/QOpenGLContext>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>

int main(int argc, char *argv[])
{
	QGuiApplication app(argc, argv);

	qputenv("QT3D_GLSL100_WORKAROUND", "");
	
	QSurfaceFormat format;
	
	if ( QOpenGLContext::OpenGLModuleType() == QOpenGLContext::LibGL) {
		format.setVersion(3, 2);
		format.setProfile(QSurfaceFormat::CoreProfile);
	}
	format.setDepthBufferSize(24);
	format.setStencilBufferSize(8);

	QQuickView view;
	view.setFormat(format);
	view.setResizeMode(QQuickView::SizeRootObjectToView);
	QObject::connect(view.engine(), &QQmlEngine::quit, &app,&QGuiApplication::quit);
	view.setSource(QUrl("qrc:/main.qml"));
	view.show();

	return app.exec();
}
